package com.catering.domain;

import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;


public class TodayYesterday {
    public static Map<String, String> ZeroTime() {
        SimpleDateFormat Spdate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar cal = Calendar.getInstance();
        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
        Date zero = cal.getTime();
        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)-1, 0, 0, 0);
        Date yzero  = cal.getTime();
        String today =Spdate.format(zero);
        String yesterday = Spdate.format(yzero);
        Map<String, String> map = new HashMap<>();
        map.put("today", today);
        map.put("yesterday", yesterday);
        return map;
    }

}
